import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:lepig/model/PageInfoModel.dart';
import 'package:lepig/model/ProductModel.dart';
import 'package:lepig/model/SelectProductTypeModel.dart';
import 'package:lepig/request/lib/HttpManager.dart';

import 'lib/NWApi.dart';
import 'lib/NWMethod.dart';

/**
 * 相关商品
 */


class RelatedParams{
  String type;
  String productId;
  String relatedVal;
}

// ignore: non_constant_identifier_names
Future<List<ProductModel>> HttpSelectRelated(BuildContext context,{RelatedParams params}) async {
  List<ProductModel> lists = new List<ProductModel>();

  Map<String, dynamic> data = new Map<String, dynamic>();
  data["type"] =params.type;
  data["productId"] =params.productId;
  data["relatedVal"] =params.relatedVal;

  print(data.values.toString());
  Map responseBody = await HttpManager()
      .request(NWApi.selectRelated, NWMethod.GET,params: data,context: context);
  List<dynamic> list = responseBody['data'];
  list.forEach((element) {
    lists.add(ProductModel.fromJson(element));
  });
  return lists;
}
